import React, {Component} from 'react';
import PropTypes from 'prop-types'  // 组件传参用的参数校验
import {withRouter} from 'react-router-dom'  // 作用：非路由组件取path值

import {TabBar} from 'antd-mobile';
import './yang-tarbar.less'

class YangTarbar extends Component {


    constructor(props) {
        super(props);
        this.state = {
            selectedTab: 'PostsTab',
            hidden: false,
            fullScreen: false,
        };
    }

    static propTypes = {
        TarBarList: PropTypes.array.isRequired,
        IsHideTatbar:PropTypes.bool.isRequired
    }

    render() {
        let {TarBarList,IsHideTatbar} = this.props
        const path = this.props.location.pathname // 请求的path
        return (
            <div>
                <TabBar
                    unselectedTintColor="#949494"
                    tintColor="#33A3F4"
                    barTintColor="white"
                    hidden={IsHideTatbar}
                >
                    {TarBarList.map((item) => (
                        <TabBar.Item
                            key={item.key}
                            title={item.title}
                            icon={ {uri:item.icon}}
                            selectedIcon={{uri:item.selectedIcon}}
                            selected={item.path === path}
                            onPress={() => this.props.history.replace(item.path)}
                        />
                    ))}
                </TabBar>
            </div>
        );
    }
}



export default withRouter(YangTarbar)